package blazingbubble.network.lobby;

import blazingbubble.game.command.JoinGameCommand;
import blazingbubble.network.lobby.strategy.GameListGameDataStrategy;
import blazingbubble.network.lobby.strategy.GameListSendingEndStrategy;
import blazingbubble.network.lobby.strategy.LoginResponseStrategy;
import blazingbubble.network.lobby.strategy.CreateGameResponseStrategy;
import blazingbubble.network.lobby.strategy.ILoginResponseResultListener;
import blazingbubble.game.ILobbyGameEventListener;
import blazingbubble.graphics.lobby.IGameListUpdateListener;

public class LobbyStrategyFactory {
	private LoginResponseStrategy loginResponse;
	private CreateGameResponseStrategy createGameResponse;
	private GameListGameDataStrategy gameListGameData;
	private GameListSendingEndStrategy gameListSendingEnd;

	public void setGameCreationListener(ILobbyGameEventListener lobbyGameEventListener) {
		getCreateGameResponseStrategy().setGameCreationListener(lobbyGameEventListener);
	}

	public void setLoginResponseResultListener(ILoginResponseResultListener loginResponseResultListener) {
		getLoginResponseStrategy().setLoginResponseResultListener(loginResponseResultListener);
	}

	public void setGameListUpdateListener(IGameListUpdateListener updateListener){
		getGameListGameDataStrategy().setGameListUpdateListener(updateListener);
		getGameListSendingEndStrategy().setGameListUpdateListener(updateListener);
	}

	public LoginResponseStrategy getLoginResponseStrategy() {
		if(loginResponse != null) {
			return loginResponse;
		}
		loginResponse = new LoginResponseStrategy();
		return loginResponse;
	}

	public CreateGameResponseStrategy getCreateGameResponseStrategy() {
		if(createGameResponse != null) {
			return createGameResponse;
		}
		createGameResponse = new CreateGameResponseStrategy();
		return createGameResponse;
	}

	public GameListGameDataStrategy getGameListGameDataStrategy(){
		if (gameListGameData == null){
			gameListGameData = new GameListGameDataStrategy();
		}
		return gameListGameData;
	}

	public GameListSendingEndStrategy getGameListSendingEndStrategy(){
		if (gameListSendingEnd == null){
			gameListSendingEnd = new GameListSendingEndStrategy();
		}
		return gameListSendingEnd;
	}

	public void setJoinGameCommand(JoinGameCommand joinGameCommand) {
		getCreateGameResponseStrategy().setJoinGameCommand(joinGameCommand);
	}
}